import os
import sys
from functools import reduce
from os.path import join as opj
from setuptools import setup
from Cython.Build import cythonize 
# from distutils.core import setup, Extension
# from Cython.Distutils import build_ext
# from DistUtilsExtra.command import build_i18n,build_help,build_icons,build_extra

__package_name__ = 'serviceloader'
__package_file__ = 'service-loader'

modules = []

package_data = {'serviceloader':['*.rng','conf/*']}

data_files = [('/etc/service-loader.d',[opj(__package_name__,'conf','service-loader.conf'),opj(__package_name__,'conf','service-loader-services.conf')])]

for lang in os.listdir(opj(__package_name__,'locale')):
	data_files.append((os.path.join(sys.prefix,'share', 'locale', lang, 'LC_MESSAGES'),[opj(__package_name__,'locale', lang, 'LC_MESSAGES','service-loader.mo')]))

for d in os.walk('serviceloader'):
	l = list(map(lambda x:x[:-2],list(filter(lambda x: x[0] != '.' and x[-2:]=='.c',d[2]))))
	if len(l) > 0:
		a=list(map(lambda x:opj(d[0],x), l ))
		for n in a:
			#modules.append(Extension('%s' % (n.replace(os.path.sep,'.'),), sources = ['%s' % (n + '.c')],language='clang'))
			modules.append(n+'.py')

packages = ['serviceloader']

setup (name = __package_name__,package_data = package_data, data_files = data_files, packages = packages,package_dir = {__package_name__:'serviceloader'},version = '1.0.0.0', description = 'Service loader',long_description = 'Service loader of any services', author='Nikolay Chesnokov', author_email='nikolaychesnokov@gmail.com' , url='http://www.gsrp5.org', license='AGPL-3'
, ext_modules = cythonize(modules))



